/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_RTSP_PLAYER_H
#define MK_RTSP_PLAYER_H
#include "MkRtspClient.h"
#include "MkRtspStreamSource.h"

class MkApi CMkRtspPlayer : public CMkRtspClient, public CMkRtspStreamSource
{
public:
    CMkRtspPlayer(CMkEvent* pEvent, CMkTimer* pTimer, MkVector<CMkRtpUdpServer*>& VecRtpUdpServer, const MkEventRemovedCallback& RemovedCb);
    ~CMkRtspPlayer();

    Uint32 Play(const MkString& RtspUrl, BOOL bStreamTcp, const MkSourceResultCallback& ResultCb, const MkEsPacketCallback& EsCb = nullptr);
    Uint32 Pause();
    Uint32 Recovery();
    Uint32 SetSpeed(float fSpeed);
    Uint32 Seek(Uint32 uSecond);
    Uint32 StopMediaSource() override;
protected:
private:
    Uint32 PlayControl(const MkPlaybackControlType& ControlType, float fSpeed, Uint32 offsetSec) override;
private:
    Uint32 OnRtpPacket(const MkCodecType& Codec, const CMkRtpPacket& RtpPacket, const MkString& Host, Uint16 Port) override;
    Uint32 OnRtcpPacket(const CMkRtcpPacket& RtcpPacket, const MkString& Host, Uint16 Port) override;
    Uint32 OnResponseError(const MkRtspStatusCode& StatusCode) override;
    Uint32 OnOptionResponse(const CMkRtspResponse& Res) override;
    Uint32 OnDescribeResponse(const CMkRtspRequest& RtspReq, const CMkRtspResponse& Res) override;
    Uint32 OnSetupResponse(const CMkRtspRequest&  RtspReq, const CMkRtspResponse& Res) override;
    Uint32 OnPlayResponse(const CMkRtspResponse& Res) override;
    Uint32 OnTearDownResponse(const CMkRtspResponse& Res) override;
    Uint32 OnClose() override;
};



#endif